/**
 * ATuanZhang
 */
package org.huanglei.android.activity;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

/**
 * @author huanglei
 * @date 2011-3-24 @
 */
public class BaseSplashActivity extends Activity {

	protected int minDisplayMs = (int) (2.5 * 1000);

	protected final String TAG = this.getClass().getName();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final long start = System.currentTimeMillis();
		new Thread(new Runnable() {
			public void run() {
				final Application app = getApplication();
				doStuffInBackground(app);
				final long duration = System.currentTimeMillis() - start;
				if (duration < minDisplayMs) {
					try {
						Thread.sleep(minDisplayMs - duration);
					} catch (InterruptedException e) {
						Thread.interrupted();
					}
				}
				startNextActivity();
				andFinishThisOne();
			}
		}).start();
	}

	protected void doStuffInBackground(Application app) {
		throw new RuntimeException("Stub!");
	}

	protected void startNextActivity() {
		throw new RuntimeException("Stub!");
	};

	protected void andFinishThisOne() {
		finish();
	}

}
